import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '@views/home/home.vue';

Vue.use(VueRouter);

const routes = [
    // 主页
    {
        path: '/',
        name: 'Home',
        component: Home,
    },

    //大类详情
    {
        path: '/category/:cid',
        name: 'Category',
        component: () => import('@views/category/category.vue'),
    },

    //最新消息
    {
        path: '/latest',
        name: 'Latest',
        component: () => import('@views/latest/latest.vue'),
    },

    //搜索页面
    {
        path: '/search',
        name: 'Search',
        component: () => import('@views/search/search.vue'),
    },

    //文章详情
    {
        path: '/post/:pid',
        name: 'Post',
        component: () => import('@views/post/post.vue'),
    },

    //教师个人信息
    {
        path: '/teacher/:tid',
        name: 'Teacher',
        component: () => import('@views/teacher/teacher.vue'),
    },

    //404页面路由
    {
        path: '/404',
        component: () => import('@views/404.vue'),
        hidden: true,
    },

    // 404 page must be placed at the end !!!
    { path: '*', redirect: '/404', hidden: true },
];

const router = new VueRouter({
    mode: 'history',
    routes,
});

export default router;
